/*
 * UStringMap.h
 *
 *  Created on: 2020年3月24日
 *      Author: chuanjiang.zh
 */

#ifndef UStringMap_H_
#define UStringMap_H_

#include "UString.h"
#include "UStringList.h"


class UStringMapPrivate;


class DLLEXPORT UStringMap
{
public:
	UStringMap();
	virtual ~UStringMap();

	UStringMap(const UStringMap& strMap);
	UStringMap& operator = (const UStringMap& strMap);

	int size() const;

	bool empty() const;

	bool getAt(int idx, UString& key, UString& value) const;
	bool find(const UString& key, UString& value) const;

	UStringMap& put(const UString& key, const UString& value);

	bool remove(const UString& key, UString& value);
	bool remove(const UString& key);
	bool removeAt(int idx, UString& key, UString& value);
	bool removeFirst(UString& key, UString& value);

	bool contains(const UString& key) const;

	UString join(char separator, char eq) const;
	UString join(const UString& separator, const UString& eq) const;

	void clear();

private:
	UStringMapPrivate*	m_pimpl;

};

inline std::ostream&  operator << (std::ostream& os, const UStringMap& strMap)
{
    os << strMap.join(';', '=');
    return os;
}

#endif /* UStringMap_H_ */
